<?php

class CategoryRelation extends CWidget
{

    public $model;

    public function init()
    {
	if (!$this->model) {
	    return false;
	}
    }

    public function run()
    {
	$display = '';
	$childs = $this->model->getChildren();
	if (empty($childs)) {
	    return $display;
	}
	$display .= '<li><ul style = "list-style-type: none;">';
	foreach ($childs as $category) {
	    $t = array(
		'<li>',
		CHtml::link($category->title, Yii::app()->createUrl('category/view', array('name' => $category->name))),
		'</li>'
	    );
	    $display .= implode($t);
	    $display .= $this->widget('application.widgets.CategoryRelation', array('model' => $category), true);
	}
	$display .= '</ul></li>';
	echo $display;
    }

}

?>
